Repository navigation
Conversation
Start Plan on zcode.z.ai requires Bearer JWT, official ZCode system gateway blocks, and proactive Aliyun traceless captcha — not the coding-plan API key path. - Replace broken Playwright reactive solver with jsdom traceless captcha - Inject official system blocks (fixes 3012 without captcha) - Bearer JWT upstream auth; auth import-jwt from ZCode desktop credentials - Proactive captcha before request with single retry on rejection - Document start-plan setup in README and config.example.yaml Fixes #2. Tested live: POST /v1/messages returns 200 with glm-5.2.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 525ff04bcc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (parsed.stream !== true) { | ||
| parsed.stream = true; | ||
| changed = true; |
There was a problem hiding this comment.
Preserve non-streaming start-plan semantics
When a /v1/messages start-plan client omits stream or sends stream:false, this rewrite forces the upstream request to stream, while the handler later only passes the upstream response through. That breaks the documented non-streaming Anthropic endpoint and the new README start-plan curl example by returning text/event-stream instead of a JSON message; either preserve the client’s stream flag or aggregate the SSE back into a non-stream response.
Useful? React with 👍 / 👎.
| const needsRetry = | ||
| detectCaptchaChallenge(opts.upstreamResp) !== null || | ||
| (await isCaptchaFailure(opts.upstreamResp)); |
There was a problem hiding this comment.
Avoid draining successful SSE responses for captcha checks
For every successful start-plan response without a captcha header, this awaits isCaptchaFailure(), which clones and reads the entire response body. On SSE responses this means proxyRequest does not return the streaming Response to the client until the upstream stream finishes, so streaming consumers receive no tokens until completion or can hang on long streams; restrict body scanning to error statuses/non-SSE responses before calling text().
Useful? React with 👍 / 👎.
New accounts need Start Plan balance buckets provisioned by the ZCode host process — OAuth alone leaves billing/balance empty (1005 exceed quota). auth onboard zai: OAuth login → encrypt-write ~/.zcode credentials → sync config.json start-plan JWT → launch ZCode → poll billing until buckets exist → save proxy credentials.
|
Thanks for this PR, it's partially accepted and merged. Contribution attributed |
Summary
Fixes #2 — makes the
auto-captchabranch actually work for ZCode Start Plan (plan: start-plan).The original
auto-captchabranch had the right reactive-captcha idea but failed in practice:coding-plan+ placeholder API key →401 token expired or incorrectx-api-keyfor JWT instead ofAuthorization: BearerstartTracelessVerification()3012even with valid captchaThis PR ports and hardens the approach from community testing (see issue #2 / PR #4), verified live:
auth import-jwt— decrypt JWT from~/.zcode/v2/credentials.jsonzcode_system.jsoninjected on every start-plan requestcaptcha_node/solver.js+ Aliyun traceless verification (scene11xygtvd), cached ~45szcode.z.ai/api/v1/zcode-plan/anthropic/v1/messages3012surfaced asaccount_blocked(not misclassified as captcha)Addresses TriDefender review feedback on PR #4:
solveCaptchawrapped in try/catch on retry pathnpm installincaptcha_node(nopostinstallhook)system-promptnormalization for malformed blocksTest plan
bun test— 174 tests passnode captcha_node/solver.js— producesVERIFY_PARAM=...auth import-jwt+plan: start-plan+POST /v1/messages→ HTTP 200, model reply"ok"(~7s TTFB)Usage
bun run src/index.ts auth import-jwt # config.yaml: auth.mode: oauth, plan: start-plan bun run src/index.tsRequires Node.js for captcha solver (auto-installed on first solve).